﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.title.zhuyonghu"/><spring:message code="message.button.add"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.title.zhuyonghu"/><spring:message code="message.button.add"/></h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first" /></a></li>
            <li class="active"><a href="#"><spring:message code="message.title.xiTongSheZhi" /></a></li>
             <li class="active"><a href="#"><spring:message code="message.title.yongHuGuanLi" /></a></li>
            <li class="active"><a href="#"><spring:message code="message.title.center_zhuyonghu" /></a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">
                    <div class="form-group form-group-xs">
                        <label for="searchPharCode"><spring:message code='message.lable.yiLiaoJiGouBianMa'/>：</label>
                        <input class="form-control" type="text" id="hospCode" placeholder="<spring:message code='message.lable.yiLiaoJiGouBianMa'/>" maxlength="50" />
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="searchPharName"><spring:message code='message.lable.yiLiaoJiGouMingCheng'/>：</label>
                        <input class="form-control" type="text" id="hospName" placeholder="<spring:message code='message.lable.yiLiaoJiGouMingCheng'/>" maxlength="200" />
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="searchPharName"><spring:message code='message.lable.suoShuDiQu'/>：</label>
                        <select id="area1" class="form-control" style="width:100px;display:inline-block;"></select>
                        <select id="area2" class="form-control" style="width:100px;display:inline-block;"></select>
                        <select id="area3" class="form-control" style="width:100px;display:inline-block;"><option value=""><spring:message code="message.select.option"></spring:message> </option></select>
                    </div>
                    <button type="button" class="btn btn-success btn-sm" onclick="search();"><spring:message code='message.button.seach'/></button>
                </div>
            </div>
        </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
          <div class=" box box-warning bottongroup">
      		  <a href="${ctx}/sysUser/zxUserList.html" class="btn btn-default btn-sm"><spring:message code='message.button.getBack'/></a>
    	</div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script type="text/javascript">
	 $(function(){
		 $('.form-inline :input').bind('keydown', function(event) {if (event.keyCode == "13") {search();}}).eq(0).focus();
	 })
	    function generateAccount(name,id,userType){
		    	$.HN.dialog.open({
		             id:id,
		             title:"<spring:message code="message.title.zhuyonghu"/><spring:message code="message.button.add"/>",
		             url:"${ctx}/sysUser/toGenerateAccount.html?id="+id+"&userType="+userType+"&name="+name,
		             width:"300px",
		             height:"185px",
		             closefunc:function(){
		            	 search();
		             }
		         });
	    }
    	
    	function search(page) {
    		var hospCode = $("#hospCode").val();
    		var hospName = $("#hospName").val();
    		var area1 = $("#area1").val();
    		var area2 = $("#area2").val();
    		var area3 = $("#area3").val();
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:{"hospCode":hospCode, "hospName":hospName, "area1":area1, "area2":area2, "area3":area3},
    	        page : (page || 1)
    	    }).trigger("reloadGrid"); //重新载入  
    	}
    
        $(function () {
            $("#gridlist").jqGrid({
                url: "${ctx}/sysUser/getHospInfoList.html",
                mtype: "post",
                datatype: "json",
                autowidth: true,
                height: 270,
                colNames: [
					'<spring:message code='message.jqGrid.cz'/>',
					'<spring:message code='message.lable.yiLiaoJiGouBianMa'/>', 
					'<spring:message code='message.lable.yiLiaoJiGouMingCheng'/>', 
					'<spring:message code='message.lable.yiLiaoJiGouLeiXing'/>', 
					'<spring:message code='message.lable.zuZhiJiGouDaiMa'/>', 
					'<spring:message code='message.lable.suoShuDiQu'/>', 
					'<spring:message code='message.lable.yiLiaoJiGouLeiXing'/>', 
					'<spring:message code='message.lable.status'/>'
                ],
                colModel: [
                    { name: 'operate', width: 6, align:"center", sortable: false,
                    	formatter : function(val, opts, rowdata) {
                    		var str="";
                    		str += "<a href='javascript:generateAccount(\""+rowdata.hospName+"\",\""+rowdata.hospId+"\",${userType});' ><spring:message code='message.lable.shengChengZhangHao'/></a>";
	                    	return str;
                  		}
                    },
                    { name: 'hospCode', width: 10, align:"center", sortable: false},
                    { name: 'hospName', width: 15, align:"left", sortable: false },
                    { name: 'hospTypeName', width: 10, align:"center", sortable: false},
                    { name: 'orgCode', width: 10, align:"center", sortable: false},
                    { name: 'arfullname', width: 10, align:"center", sortable: false},
                    { name: 'hospLevelId', width: 10, align:"center", sortable: false},
                    { name: 'status', width: 5, align: 'center',hidden:true, sortable: false,
                    	formatter : function(val, opts,rowdata) {
							var str = "";
							if (rowdata.status == 1) {
								str = "<spring:message code='message.button.start'/>";
							}
							if (rowdata.status == 2) {
								str = "<spring:message code='message.button.stop'/>";
							}
							if (rowdata.status == 3) {
								str = "<spring:message code='message.button.combine'/>";
							}
							return str;
						}
                    }
                ],
                rowNum: 20,
                rowList: [10, 20, 30],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
                caption: "<spring:message code='message.lable.yiLiaoJiGouLieBiao'/>",
                gridComplete:function(){
                    autoRNWidth("gridlist");
                },
                jsonReader: {
                    id: "hospId"
                }
            });
            
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
            
  		  $("#area1").HNSelect({
	            url: "${pageContext.request.contextPath}/selectController/getArea.html", 
	            data: { ID: '000000' },  
	            defaultText: "<option value=''><spring:message code='message.select.option'/></option>",
	            func: function () {
	                 $("#area2").HNSelect({
	                    parent_selector: "#area1", 
	                    url: "${pageContext.request.contextPath}/selectController/getArea.html", 
	                    dataid: "ID",
	                    defaultText: "<option value=''><spring:message code='message.select.option'/></option>",
	                    		  func: function () {
	                                  $("#area3").HNSelect({
	                                      parent_selector: "#area2", 
	                                      url: "${pageContext.request.contextPath}/selectController/getArea.html", 
	                                      dataid: "ID", 
	                                      defaultText: "<option value=''><spring:message code='message.select.option'/></option>"
	                                  });
	                              }
	                }); 
	            }
	        });
        });
    </script>
</body>
</html>
